package com.api.regression.group.editnotification;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.NotificationApiType;
import com.zyncro.api.model.SubscriptionEventApiType;

@ContextConfiguration(locations = { "classpath:/group/group-context.xml" })
public class EditNotificationNotParticipant extends AbstractApiTest {

	@Value("#{groupsearch['user.notParticipant'].appId}")
	private String userUrn;

	@Value("#{groupsearch['user.notParticipant'].password}")
	private String userPassword;

	@Value("#{groupsearch['group.toEditNotifications'].urn}")
	private String groupUrn;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testEditEmailFileEvents() throws ZyncroApiException {

		NotificationApiType notificationType = NotificationApiType.EMAIL;
		SubscriptionEventApiType eventNotificationType = SubscriptionEventApiType.FILE_GROUP_EVENTS;
		boolean enabled = true;

		getApi().getService(IGroupApiService.class).editNotification(groupUrn, notificationType, eventNotificationType, enabled);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testEditFeedMembersEvents() throws ZyncroApiException {

		NotificationApiType notificationType = NotificationApiType.FEED;
		SubscriptionEventApiType eventNotificationType = SubscriptionEventApiType.MEMBERS_EVENTS;
		boolean enabled = true;

		getApi().getService(IGroupApiService.class).editNotification(groupUrn, notificationType, eventNotificationType, enabled);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testEditEmailMessagesEvents() throws ZyncroApiException {

		NotificationApiType notificationType = NotificationApiType.EMAIL;
		SubscriptionEventApiType eventNotificationType = SubscriptionEventApiType.MESSAGES_EVENTS;
		boolean enabled = true;

		getApi().getService(IGroupApiService.class).editNotification(groupUrn, notificationType, eventNotificationType, enabled);
	}

}
